package com.ht.service.impl;

import com.ht.dto.Posts;
import com.ht.dto.User;
import com.ht.service.PostsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Properties;

@Service
public class PostsServiceImpl implements PostsService {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public List<Posts> selectPosts(User user) {
        Query query = new Query(Criteria.where("userId").is(user.getId()));
        List<Posts> posts = mongoTemplate.find(query, Posts.class);
        return posts;
    }
}
